/**
 * Created by Administrator on 2017/1/9.
 */
$(function () {
    $('#start_datetime').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });

    $('#end_datetime').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });
});

$(function () {
    var $type = $('[name="roadshow_type"]');

    $type.on('change',function() {

        if ($type.filter(':checked').val() == '分析师') {
            $('#analyst_container').show();
            $('#company_container').hide();
            $('#expert_container').hide();

            $('#recommend').attr("name",'recommend');
            $('#name_analyst').attr("name",'name_analyst');
            $('#person_name_analyst').attr("name",'person_name_analyst');
            $('#content_analyst').attr("name",'content_analyst');

            $('#visit_company').removeAttr("name");
            $('#company_name_company').removeAttr("name");
            $('#person_name_company').removeAttr("name");
            $('#type_money_company').removeAttr("name");

            $('#expert_name_expert').removeAttr("name");
            $('#visit_expert').removeAttr("name");
            $('#person_name_expert').removeAttr("name");
            $('#content_expert').removeAttr("name");


        } else if($type.filter(':checked').val() == '上市公司') {
            $('#analyst_container').hide();
            $('#company_container').show();
            $('#expert_container').hide();

            $('#recommend').removeAttr("name");
            $('#name_analyst').removeAttr("name");
            $('#person_name_analyst').removeAttr("name");
            $('#content_analyst').removeAttr("name");

            $('#visit_company').attr("name",'visit_company');
            $('#company_name_company').attr("name",'company_name_company');
            $('#person_name_company').attr("name",'person_name_company');
            $('#type_money_company').attr("name",'type_money_company');

            $('#expert_name_expert').removeAttr("name");
            $('#visit_expert').removeAttr("name");
            $('#person_name_expert').removeAttr("name");
            $('#content_expert').removeAttr("name");

        } else {
            $('#analyst_container').hide();
            $('#company_container').hide();
            $('#expert_container').show();

            $('#recommend').removeAttr("name");
            $('#name_analyst').removeAttr("name");
            $('#person_name_analyst').removeAttr("name");
            $('#content_analyst').removeAttr("name");

            $('#visit_company').removeAttr("name");
            $('#company_name_company').removeAttr("name");
            $('#person_name_company').removeAttr("name");
            $('#type_money_company').removeAttr("name");

            $('#expert_name_expert').attr("name",'expert_name_expert');
            $('#visit_expert').attr("name",'visit_expert');
            $('#person_name_expert').attr("name",'person_name_expert');
            $('#content_expert').attr("name",'content_expert');
        }

        $('#type').val($type.filter(':checked').val());
    });
});

$(function () {
    var $range = $("[name='roadshow_recommend']");
    $range.on('change', function () {
        $('#group_containers').slideToggle(200);
        $('#recommend').val($range.filter(':checked').val());

        if ($range.filter(':checked').val() == '公司深度推荐') {
            $('#company_name_analyst_1').attr("name",'company_name_analyst_1');
            $('#operate_analyst_1').attr("name",'operate_analyst_1');
        }else{
            $('#company_name_analyst_1').removeAttr("name");
            $('#operate_analyst_1').removeAttr("name");

            $('#company_name_analyst_2').removeAttr("name");
            $('#operate_analyst_2').removeAttr("name");

            $('#company_name_analyst_3').removeAttr("name");
            $('#operate_analyst_3').removeAttr("name");
        }
    })
});

$(function () {
    var $range = $("[name='money_type']");
    $range.on('change', function () {
        $('#type_money_company').val($range.filter(':checked').val());
    })
});

$(function () {
    var $range = $("[id='plus_1']");
    $range.on('click', function () {
        $('#group_container_2').show();
        $('#plus_1').hide();

        $('#company_name_analyst_2').attr("name",'company_name_analyst_2');
        $('#operate_analyst_2').attr("name",'operate_analyst_2');
    })
});

$(function () {
    var $range = $("[id='plus_2']");
    $range.on('click', function () {
        $('#group_container_3').show();
        $('#plus_2').hide();
        $('#minus_1').hide();

        $('#company_name_analyst_3').attr("name",'company_name_analyst_3');
        $('#operate_analyst_3').attr("name",'operate_analyst_3');
    })
});

$(function () {
    var $range = $("[id='minus_1']");
    $range.on('click', function () {
        $('#group_container_2').hide();
        $('#plus_1').show();

        $('#company_name_analyst_2').removeAttr("name");
        $('#operate_analyst_2').removeAttr("name");
    })
});
$(function () {
    var $range = $("[id='minus_2']");
    $range.on('click', function () {
        $('#group_container_3').hide();
        $('#plus_2').show();
        $('#minus_1').show();

        $('#company_name_analyst_3').removeAttr("name");
        $('#operate_analyst_3').removeAttr("name");
    })
});

